package v3.chapter7.stateTest3;

public class Run {

	// 验证Blocked
	
	// NEW,
	// RUNNABLE,
	// TERMINATED,
	
	// BLOCKED,
	// WAITING,
	// TIMED_WAITING,
	public static void main(String[] args) {
		MyThread1 t1 = new MyThread1();
		t1.setName("a");
		t1.start();
		MyThread2 t2 = new MyThread2();
		t2.setName("b");
		t2.start();
		System.out.println("main方法中的t2状态：" + t2.getState());
	}

}

class MyThread2 extends Thread{
	@Override
	public void run() {
		MyService.serviceMethod();
	}
}

class MyThread1 extends Thread{
	@Override
	public void run() {
		MyService.serviceMethod();
	}
}

class MyService{
	synchronized static public void serviceMethod() {
		try {
			System.out.println(Thread.currentThread().getName() + "进入了业务方法！");
			Thread.sleep(10000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}